package com.co.controller;

import com.co.utils.Constants;
import com.co.utils.JPage;
import com.co.utils.Language;
import com.co.utils.Logger;

public class IndexPageController {

	private static IndexPageController indexPageControllerInstance;
	private GlobalConfigurationManager gcmInstance;
	private ViewManager viewManager;
	private JPage page;

	public IndexPageController() {
		gcmInstance = GlobalConfigurationManager.getInstance();
		viewManager = ViewManager.getInstance();
	}

	public static IndexPageController getInstance() {
		if (indexPageControllerInstance == null) {
			indexPageControllerInstance = new IndexPageController();
		}
		return indexPageControllerInstance;
	}

	public void setLanguage(int selectedIndex) {
		gcmInstance.setLanguage(Language.getLanguage(selectedIndex));
	}

	public void goToLoginPage() {
		Logger.showMessage("- goToLoginPage -");
		viewManager.goToPage(Constants.LOGIN_PAGE);
	}

	private void setPage(JPage page) {
		this.page = page;
	}

	private JPage getPage() {
		return this.page;
	}

	public void configure(String pageId, JPage page) {
		setPage(page);
		gcmInstance.configurePage(page);
		viewManager.suscriptPage(pageId, page);
	}

}